/*
ID:luongho3
TASK:butter
LANG:C++
*/
#include <iostream>
#include <fstream>
using namespace std;
#define NEDGE 1500
#define NVERT 810
#define NCOW 510
#define ISFREE 1
#define NOTFREE 0
#define INF 1000000000
ifstream fin("butter.in");
ofstream fout("butter.out");
int cowp[NCOW], hascow[NVERT];
int mat[NVERT][NVERT], elen[NVERT][NVERT], deg[NVERT];
int heap[NVERT], pos[NVERT], nheap, isfree[NVERT], label[NVERT];;
int nVert, nCow, nEdge;
int mVal = INF;
void load_graph() {
    fin >> nCow >> nVert >> nEdge;
    int i,j,k,l;
    for (i=1;i<=nVert;++i) {
        hascow[i] = 0;
    }
    for (i=1;i<=nCow;++i) {
        fin >> cowp[i];
        hascow[cowp[i]]++;
    }
    for (i=1;i<=nVert;++i) {
        deg[i] = 0;
    }
    for (i=1;i<=nEdge;++i) {
        fin >> j >> k >> l;
        deg[j]++;
        deg[k]++;
        mat[j][deg[j]] = k;
        elen[j][deg[j]] = l;
        mat[k][deg[k]] = j;
        elen[k][deg[k]] = l;
    }
}
void push_heap(int vert) {
     int child, parent;
     child = pos[vert];
     if (child==0) {
        nheap++;
        child = nheap;
     }
     parent = child/2;
     while (parent>0 && label[heap[parent]] > label[vert]) {
           heap[child] = heap[parent];
           pos[heap[child]] = child;
           child = parent;
           parent = child/2;
     }
     heap[child] = vert;
     pos[vert] = child;
}
int pop_heap() {
    int re = heap[1];
    int vert = heap[nheap];
    nheap--;
    int node = 1;
    int child;
    while (node*2 <= nheap) {
          child = node*2;
          if (child<nheap && label[heap[child+1]] < label[heap[child]]) {
             child++;
          }
          if (label[vert]<label[heap[child]]) {
             break;
          }
          heap[node] = heap[child];
          pos[heap[node]]=node;
          node = child;
    }
    heap[node] = vert;
    pos[vert] = node;
    return re;
}
int heap_dj(int vert) {
    //init
    int i,j,k,l,re;
    nheap = 0;
    for (i=1;i<=nVert;++i) {
        label[i] = INF;
        isfree[i] = ISFREE;
        heap[i] = 0;
        pos[i] = 0;
    }
    l = nCow;
    re = 0;
    label[vert] = 0;
    push_heap(vert); ///
    for (i=1;i<=nVert;++i) {
          int idx = pop_heap(); ///
          if (idx == 0) {
             break;
          }
          isfree[idx] = NOTFREE;
          if (hascow[idx]>0) {
             l-=hascow[idx];
             re += (label[idx]*hascow[idx]);
          }
          if (l==0) {
             break;
          }
          if (re>=mVal) {
            break;
          }
          for (j=1;j<=deg[idx];++j) {
              k = mat[idx][j];
              if (isfree[k] == ISFREE && label[idx] + elen[idx][j] < label[k]) {
                 label[k] = label[idx] + elen[idx][j];
                 push_heap(k);
              }
          }
    }
    return re;
}
int main() {
    load_graph();
    int i,j;//,idx;
    for (i=1;i<=nVert;++i) {
        j = heap_dj(i);
        if (j<mVal) {
           mVal = j;
           //idx = i;
        }
    }
    fout << mVal << "\n";
    //fout << idx;
    return 0;
}
